package reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class ReflectDemo7 {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        Person p=new Person();
        p.say("你好");

        Class cls=Class.forName("reflect.Person");
        Object o = cls.newInstance();

        Method method = cls.getDeclaredMethod("say", String.class);
        method.invoke(o,"有能好好果汁吃");

        //Method method1=cls.getEnclosingMethod("say",String.class,int.class);

    }
}
